package com.zy.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author LittleDesire
 * @description 全局处理异常类，只要加上@ControllerAdvice注解，spring将会托管所有异常
 * @date 2022-04-08 周五 14:41
 * @since 17
 */
@ControllerAdvice
public class ExceptionController {
    @ExceptionHandler
    @ResponseBody
    public String exceptionHandler(Exception e) {
        return e.getMessage();
    }

}
